//
//  LXNavigationViewController.m
//   
//
//  Created by will on 16/7/16.
//  Copyright © 2016年 leewei. All rights reserved.
//

#import "LXNavigationViewController.h"

@interface LXNavigationViewController ()

@end

@implementation LXNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    //如果push进来不是第一个控制器
    if (self.childViewControllers.count > 0) {
        [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
//        [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.size = CGSizeMake(40, 40);
//
        [btn setImage:[UIImage imageNamed:@"nav_fanhui"] forState:UIControlStateNormal];
//        [btn setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
//        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//                [btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//         设置btn的内容左对齐
//        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//                 设置btn的内容向向左偏移
        btn.contentEdgeInsets =UIEdgeInsetsMake(0, -25, 0, 0);
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
        // 隐藏标签栏
        viewController.hidesBottomBarWhenPushed = YES;
    }
    // super放后面，让viewController可以覆盖原先的设置
    [super pushViewController:viewController animated:animated];
}

- (void)back {
    
    [self popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
